<?php

namespace App\Kuafu\Shop\Service;

use App\Kuafu\Base\Service\BaseService;
use App\Kuafu\Shop\Enum\ShopCacheEnum;
use App\Kuafu\Shop\Model\Shop;
use App\Kuafu\Shop\Model\ShopArchives;
use Illuminate\Support\Facades\Cache;


class ShopArchivesService extends BaseService
{
    /**
     * 返回门店附件信息
     *
     * @param int $shopId
     * @return array
     */
    public static function getArchivesInfo(int $shopId): array
    {
        return Cache::remember(ShopCacheEnum::getShopArchivesInfo($shopId), getSwitchCacheTime(86400),
            function () use ($shopId) {
                $result = ShopArchives::query()->where('shopId', $shopId)->first();
                return [
                    'wechat'               => $result->wechat ?? '',
                    'wechatUrl'            => $result->wechatUrl ?? '',
                    'wechatPic'            => $result->wechatPic ?? '',
                    'eWechat'              => $result->eWechat ?? '',
                    'eWechatUrl'           => $result->eWechatUrl ?? '',
                    'eWechatPic'           => $result->eWechatPic ?? '',
                    'manageEWechatPic'     => $result->manageEWechatPic ?? '',
                    'manageEWechatUrl'     => $result->manageEWechatUrl ?? '',
                    'minSelfDeliveryPrice' => $result->minSelfDeliveryPrice ?? 0,
                    'selfDeliveryNotice'   => $result->selfDeliveryNotice ?? '',
                    'isOpenSelfDelivery'   => $result->isOpenSelfDelivery ?? 0,
                    'cameraStatus'         => $result->cameraStatus ?? 0,
                ];
            });
    }

}
